import {
	request
} from "../common/config.js"

//获取歌单信息
export function getDetailList(id) {
	return request({
		url: `/playlist/detail`,
		method: 'get',
		params: {
			id
		}
	})
}
export default class SongModel {
	constructor(rawData) {
		const {
			creator: {
				userId = "",
				nickname = "未知用户",
				avatarUrl = '/static/default_avatar.png',
			} = {},
			coverImgUrl = '',
			description = "",
			name = "",
			score = "",
			trackIds = [],
			commentCount = 0,
			shareCount = 0,
			subscribedCount = 0,
			tags = 0
		} = rawData
		this.uid = userId;
		this.uname = nickname;
		this.uavatar = avatarUrl;
		this.cover = coverImgUrl;
		this.desc = description;
		this.Tname = name;
		this.scores = score;
		this.ids = trackIds;
		this.comment = commentCount;
		this.share = shareCount;
		this.subscribed = subscribedCount;
		this.tag = tags
	}
}


// 获取歌单的所有歌曲
export function getSongList(list) {
	return request({
		url: `/song/detail?ids=${list}`,
		method: 'get'
	})
}

// 播放歌曲
export function playGdMusic(id) {
	return request({
		url: `/song/url?id=${id}`,
		method: 'get'
	})
}

export function getInspectMusic(id) {
	return request({
		url: '/check/music',
		method: 'get',
		params: {
			id
		}
	})
}

// 评论区
export function playcomments(id, limit) {
	return request({
		url: '/comment/playlist',
		method: 'get',
		params: {
			id,
			limit
		}
	})
}
// 获取歌词
export function getLyric(id) {
	return request({
		url: `/lyric`,
		method: 'get',
		params:{
			id
		}
	})
}

export function getSubscribers(id) {
	return request({
		url: `/playlist/subscribers?id=${id}&limit=5`,
		method: 'get '
	})
}

export function getLikeMusic(id, states) {
	return request({
		url: `/like?id=${id}&like=${states}`,
		method: 'get'
	})
}

// 收藏、取消收藏歌单
export function PostSubscribe(t, id) {
	return request({
		url: "/playlist/subscribe",
		method: "post",
		params: {
			t,
			id
		}
	})
}